package org.osami.gateway.sensor.mock;

import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Provides;
import org.apache.felix.ipojo.annotations.ServiceProperty;
import org.osami.gateway.sensor.protocol.IMessageHandler;
import org.osami.gateway.sensor.protocol.IMessageSource;

/**
 * Created by IntelliJ IDEA.
 * User: guillaume
 * Date: 17 juin 2010
 * Time: 14:23:21
 * To change this template use File | Settings | File Templates.
 */
@Component
@Provides(specifications = IMessageSource.class)
public class PseudoDiscoveryMessageSource implements IMessageSource {

    @ServiceProperty(value = "discovery")
    private String type;

    private IMessageHandler handler;

    public void registerHandler(IMessageHandler handler) {
        this.handler = handler;
        handler.handle(new PseudoMessage("O1Htest-node-id!localhost!1234"));
        handler.handle(new PseudoMessage("O1Mtest-node-id!Temp|SI-C;Hydro|SI-%;Light|SI-lx!"));
        //handler.handle(new PseudoMessage("O1Mtest-node-id!Temp|U14-SHT1x;Hydro|U12-SHT1x;Light|SI-lx!"));
        //handler.handle(new PseudoMessage("O1Mtest-node-id!Temp|U12-SHT1x;Hydro|U8-SHT1x;Light|SI-lx!"));
    }

    public void unregisterHandler(IMessageHandler handler) {
        this.handler = null;
    }
}
